package com.multipleThread.p719;

import java.util.Calendar;

/**
 * @author 罗俊华
 * @date 2021/4/27 - 8:53 上午
 * 筷子
 */
public class Chopstick {

    private boolean isTaken;

    Calendar c = Calendar.getInstance();
    {
        c.set(Calendar.MINUTE,30);
        c.set(Calendar.SECOND,0);
    }

    public synchronized void take() {
        try {
            while (isTaken) {
                wait();
            }
            this.isTaken = true;
        } catch (InterruptedException e) {

        }
    }

    public synchronized void drop() {
        this.isTaken = false;
    }

}
